package wrapper

import (
	"github.com/asim/go-micro/v3/client"
	"context"
	"emicro_test/emicro_9/grpc_server/user/common"
	"github.com/go-micro/plugins/v3/wrapper/trace/opentracing"
	"log"
)


type CliWrapper struct {
	client.Client
}

func (c *CliWrapper) Call(ctx context.Context, req client.Request, rsp interface{}, opts ...client.CallOption) error{
	log.Println("client wrapper!!!")
	return c.Client.Call(ctx, req, rsp, opts...)
}

func NewCliWrapper(c client.Client) client.Client{
	return &CliWrapper{c}
}

func ClientTrace(service *common.EmicroService) client.Wrapper{
	tracer := GetTracer(common.ServerName, service.Addr, common.Config)
	tracerHandler := opentracing.NewClientWrapper(tracer)
	return tracerHandler
}